<?php 
require_once('../Connections/learnConn.php');

//echo $nis .' - '. $k .' - '. $ks .' - '. $kp;
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
$nis = $_GET['nis'];
$k = $_GET['k'];
$ks = $_GET['ks'];
$kp = $_GET['kp'];

mysql_select_db($database_learnConn, $learnConn);
$query_hapus = sprintf("DELETE FROM nilai WHERE nis=%s AND kd_kelas=%s AND kd_kat_kelas=%s AND kd_matpel=%s", 
						GetSQLValueString($nis, "text"), 
						GetSQLValueString($k, "text"), 
						GetSQLValueString($ks, "text"),
						GetSQLValueString($kp, "text"));

$jadwal = mysql_query($query_hapus, $learnConn) or die(mysql_error());
//$row_jadwal = mysql_fetch_assoc($jadwal);
//$totalRows_jadwal = mysql_num_rows($jadwal);
//header('location:index2.php?halaman='.$halaman);
header("location:list_siswa.php?kode_matpel=$kp&kode_kelas=$k&kode_sub_kelas=$ks");
?>